import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);


import Main from '@/view/main'
import In from '@/view/in'
import List from '@/view/list'
import Outed from '@/view/outed'
import Out from '@/view/out'
import Detail from '@/view/detail'
import Out_detail from '@/view/out_detail'
import Outed_detail from '@/view/outed_detail'
import login from '@/view/login'

const routes = [
    {path: '/login', name: '用户登陆', component: login},
    {path: '/', redirect: '/in'},
    {
        path: '/main', name: '首页', component: Main,
        children: [
            {path: '/in', name: '入库', component: In},
            {path: '/list', name: '库存', component: List},
            {path: '/outed', name: '已出库', component: Outed},
            {path: '/out', name: '出库', component: Out},
        ]
    },
    {path: '/detail/:id', name: '入库详情', component: Detail, props: true},
    {path: '/out_detail/:id', name: '出库详情', component: Out_detail, props: true},
    {path: '/outed_detail/:id', name: '已出库详情', component: Outed_detail, props: true},

    // {path: '/outed_detail/:id',name: 'detail',component: Detail},  // outed_detail
    // {path: '/in_detail/:id',name: 'detail',component: Detail},
    // {path: '/out_detail/:id',name: '出库',component: Out},
];

const router = new Router({routes: routes});

router.beforeEach((to, from, next) => {
    const title = to.meta && to.meta.title;
    if (title) {
        document.title = title;
    }
    next();
});

export {
    router
};
